/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/02/18
* File: serializer.cpp
* Blog: http://www.cnblogs.com/zengqh/
**/

#include "serializer.h"

namespace HY
{
	Serializer::~Serializer()
	{
	}

	bool Serializer::WriteString(const std::string& value)
	{
		const char* str = value.c_str();

		unsigned length = strlen(str);

		return Write(str, length + 1) == length + 1;
	}

	bool Serializer::WriteLine(const std::string& value)
	{
		bool ret = true;
		unsigned char b1 = 13;
		unsigned char b2 = 10;

		const char* str = value.c_str();

		unsigned length = strlen(str);

		ret &= (Write(str, length) == length);
		ret &= (WriteBin(b1) == 1);
		ret &= (WriteBin(b2) == 1);

		return ret;
	}
}